# import data
data_path <- "../data/preprocessed/omnibus/omnibus_bl_corrected_pickups.csv"
all_data <- fread(data_path)
## Setup ##
palette <- dict(
list(
"s30" = "#a30f15",
"d30" = "#07509b",
"s30-a" = "#fb6949",
"d30-a" = "#6aafd2",
"a-1" = "#4f1b31",
"a-2" = "#d6819b"
)
)
## Isolate experiments and summarize ##
sr_30_all <- all_data %>%
filter(exp == "sr_30") %>%
mutate(unsigned_obj_angle = obj_angle_3cm_move * obj_shape_sign * -1) %>%
mutate(unsigned_hand_angle = hand_angle_3cm_move * obj_shape_sign * -1)
sr_30_ppt_training <- sr_30_all %>%
filter(block_num == 16) %>%
mutate(trial_set = case_when(
trial_num <= 141 ~ 1,
trial_num >= 310 ~ 2,
TRUE ~ 100
))
sr_30_clamped <- sr_30_all %>%
filter(block_num > 16, type == "clamped") %>%
mutate(trained_obj_factor = case_when(
trainedfirst_obj_shape == obj_shape ~ "trained_obj",
TRUE ~ "untrained_obj"
)) %>%
mutate(trained_hand_factor = case_when(
hand == "r" ~ "trained_hand",
TRUE ~ "untrained_hand"
)) %>%
mutate(trained_obj_hand_factor = paste0(trained_obj_factor, "_", trained_hand_factor))
### DR 30 ###
dr_30_all <- all_data %>%
filter(exp == "dr_30") %>%
mutate(unsigned_obj_angle = obj_angle_3cm_move * obj_shape_sign * -1) %>%
mutate(unsigned_hand_angle = hand_angle_3cm_move * obj_shape_sign * -1)
dr_30_ppt_training <- dr_30_all %>%
filter(block_num == 7) %>%
mutate(trial_set = case_when(
trial_num <= 78 ~ 1,
trial_num >= 247 ~ 2,
TRUE ~ 100
))
# note: blocks 8 and 11 are include clamps, 13 is exclude clamps
dr_30_incl_clamp <- dr_30_all %>%
filter(block_num %in% c(8, 11))
dr_30_excl_clamp <- dr_30_all %>%
filter(block_num %in% c(13, 14))
# both experiment rbind
both_ppt_training <- rbind(sr_30_ppt_training, dr_30_ppt_training)
dr_30_ppt_incl_clamped <- dr_30_incl_clamp %>%
group_by(ppid, obj_shape_sign) %>%
summarise(
ppt_mean_angle = mean(obj_angle_3cm_move),
ppt_ci_angle = vector_confint(obj_angle_3cm_move)
)
`summarise()` has grouped output by 'ppid'. You can override using the `.groups` argument.
dr_30_ppt_incl_clamped$obj_shape_sign <- factor(
dr_30_ppt_incl_clamped$obj_shape_sign
)
dr_30_exp_incl_clamped <- dr_30_ppt_incl_clamped %>%
group_by(obj_shape_sign) %>%
summarise(
mean_angle = mean(ppt_mean_angle),
ci_angle = vector_confint(ppt_mean_angle)
)
# add a difference column
dr_30_ppt_incl_clamped <- dr_30_ppt_incl_clamped %>%
group_by(ppid) %>%
mutate(
diff = ppt_mean_angle - lag(ppt_mean_angle)
)
# plot the trial sets
p <- dr_30_ppt_incl_clamped %>%
ggplot(
aes(
x = obj_shape_sign, y = ppt_mean_angle,
colour = ppid
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = "Trial Set",
y = "Hand Angle (°)"
) +
geom_point() +
geom_line(aes(group = ppid), alpha = 0.2)
ggplotly(p)
# plot the diffs
p <- dr_30_ppt_incl_clamped %>%
filter(obj_shape_sign == 1) %>%
ggplot(
aes(
x = obj_shape_sign,
colour = ppid
)
) +
theme_classic() +
theme(legend.position = "none") +
geom_hline(
yintercept = c(0), linewidth = 0.4,
colour = "#CCCCCC", linetype = "dashed"
) +
# add data
geom_beeswarm(
aes(
y = diff
),
alpha = 0.5,
size = 1
)
ggplotly(p)
Removing ppt “dr_30_2”
data_ppt <- dr_30_ppt_incl_clamped %>%
filter(ppid != "dr_30_2")
# summary statistics
data_ppt %>%
group_by(obj_shape_sign) %>%
summarise(
mean = mean(ppt_mean_angle),
ci = vector_confint(ppt_mean_angle),
n = n()
)
# Comparison stats
# paired t-test
group1 <- data_ppt %>%
filter(obj_shape_sign == "-1") %>%
pull(ppt_mean_angle)
group2 <- data_ppt %>%
filter(obj_shape_sign == "1") %>%
pull(ppt_mean_angle)
diffs <- group2 - group1
t.test(diffs)
One Sample t-test
data: diffs
t = -4.2632, df = 28, p-value = 0.0002067
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-4.756845 -1.669237
sample estimates:
mean of x
-3.213041
# Effect size
cohen.d(group1, group2)
Cohen's d
d estimate: 0.5720102 (medium)
95 percent confidence interval:
lower upper
0.03528311 1.10873733
# Bayes factor
ttestBF(x = diffs)
Bayes factor analysis
--------------
[1] Alt., r=0.707 : 135.9736 ±0%
Against denominator:
Null, mu = 0
---
Bayes factor type: BFoneSample, JZS
dr_30_ppt_excl_clamped <- dr_30_excl_clamp %>%
group_by(ppid, obj_shape_sign) %>%
summarise(
ppt_mean_angle = mean(obj_angle_3cm_move),
ppt_ci_angle = vector_confint(obj_angle_3cm_move)
)
`summarise()` has grouped output by 'ppid'. You can override using the `.groups` argument.
dr_30_ppt_excl_clamped$obj_shape_sign <- factor(
dr_30_ppt_excl_clamped$obj_shape_sign
)
dr_30_exp_excl_clamped <- dr_30_ppt_excl_clamped %>%
group_by(obj_shape_sign) %>%
summarise(
mean_angle = mean(ppt_mean_angle),
ci_angle = vector_confint(ppt_mean_angle)
)
# add a difference column
dr_30_ppt_excl_clamped <- dr_30_ppt_excl_clamped %>%
group_by(ppid) %>%
mutate(
diff = ppt_mean_angle - lag(ppt_mean_angle)
)
# plot the trial sets
p <- dr_30_ppt_excl_clamped %>%
ggplot(
aes(
x = obj_shape_sign, y = ppt_mean_angle,
colour = ppid
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = "Trial Set",
y = "Hand Angle (°)"
) +
geom_point() +
geom_line(aes(group = ppid), alpha = 0.2)
ggplotly(p)
# plot the diffs
p <- dr_30_ppt_excl_clamped %>%
filter(obj_shape_sign == 1) %>%
ggplot(
aes(
x = obj_shape_sign,
colour = ppid
)
) +
theme_classic() +
theme(legend.position = "none") +
geom_hline(
yintercept = c(0), linewidth = 0.4,
colour = "#CCCCCC", linetype = "dashed"
) +
# add data
geom_beeswarm(
aes(
y = diff
),
alpha = 0.5,
size = 1
)
ggplotly(p)
Removing ppt “dr_30_2”
data_ppt <- dr_30_ppt_excl_clamped %>%
filter(ppid != "dr_30_2")
# summary statistics
data_ppt %>%
group_by(obj_shape_sign) %>%
summarise(
mean = mean(ppt_mean_angle),
ci = vector_confint(ppt_mean_angle),
n = n()
)
# Comparison stats
# paired t-test
group1 <- data_ppt %>%
filter(obj_shape_sign == "-1") %>%
pull(ppt_mean_angle)
group2 <- data_ppt %>%
filter(obj_shape_sign == "1") %>%
pull(ppt_mean_angle)
diffs <- group2 - group1
t.test(diffs)
One Sample t-test
data: diffs
t = -1.8713, df = 28, p-value = 0.07178
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-6.3401315 0.2864248
sample estimates:
mean of x
-3.026853
# Effect size
cohen.d(group1, group2)
Cohen's d
d estimate: 0.4200617 (small)
95 percent confidence interval:
lower upper
-0.1117851 0.9519085
# Bayes factor
ttestBF(x = diffs)
Bayes factor analysis
--------------
[1] Alt., r=0.707 : 0.9124751 ±0.02%
Against denominator:
Null, mu = 0
---
Bayes factor type: BFoneSample, JZS
sr_30_ppt_trial_sets <- sr_30_ppt_training %>%
filter(trial_set < 5) %>%
group_by(ppid, trial_set, targetAngle) %>%
summarise(
mean_trial_set_angle = mean(unsigned_hand_angle),
n()
)
`summarise()` has grouped output by 'ppid', 'trial_set'. You can override using the `.groups` argument.
sr_30_ppt_trial_sets$ppid <- as.factor(sr_30_ppt_trial_sets$ppid)
sr_30_ppt_trial_sets$trial_set <- as.factor(sr_30_ppt_trial_sets$trial_set)
sr_30_ppt_trial_sets$targetAngle <- as.factor(sr_30_ppt_trial_sets$targetAngle)
sr_30_trial_set_devs <- sr_30_ppt_trial_sets %>%
group_by(trial_set, targetAngle) %>%
summarise(
trial_set_mean = mean(mean_trial_set_angle),
trial_set_ci = vector_confint(mean_trial_set_angle)
)
`summarise()` has grouped output by 'trial_set'. You can override using the `.groups` argument.
data_ppt <- sr_30_ppt_trial_sets
data_trial_set <- sr_30_trial_set_devs
# set up plot
p <- data_trial_set %>%
ggplot(
aes(
x = trial_set, y = trial_set_mean
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = "Hand Angle (°)"
)
# add horizontal lines
p <- p +
geom_hline(
yintercept = c(0, 30), linewidth = 0.4,
colour = "#CCCCCC", linetype = "solid"
) +
geom_hline(
yintercept = c(15), linewidth = 0.4,
colour = "#CCCCCC", linetype = "dashed"
)
# add axis ticks
p <- p +
scale_y_continuous(
limits = c(-15, 40),
breaks = c(0, 15, 30),
labels = c(0, 15, 30)
)
# set font size to 11
p <- p +
theme(text = element_text(size = 11))
# add data points
p <- p +
geom_beeswarm(
data = data_ppt,
aes(y = mean_trial_set_angle, colour = targetAngle),
alpha = 0.5,
size = 1
) +
geom_linerange(aes(
ymin = trial_set_mean - trial_set_ci,
ymax = trial_set_mean + trial_set_ci
), alpha = 0.1, lwd = 2) +
geom_point()
# p <- p +
# scale_color_manual(
# values = c(
# "#555555", "#555555"
# )
# )
p <- p +
scale_x_discrete(
labels = c(
"Init\nT", "Fin\nT"
)
)
p
# ANOVA using afex (identical values to ez but ez doesn't remove missing rows)
(temp_ANOVA <- aov_car(mean_trial_set_angle ~ targetAngle * trial_set + Error(ppid / (targetAngle * trial_set)), data_ppt))
Anova Table (Type 3 tests)
Response: mean_trial_set_angle
Effect df MSE F ges p.value
1 targetAngle 1.97, 61.06 44.75 0.06 <.001 .943
2 trial_set 1, 31 132.95 0.71 .006 .406
3 targetAngle:trial_set 1.97, 61.19 36.62 1.40 .006 .253
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1
Sphericity correction method: GG
bf <- anovaBF(mean_trial_set_angle ~ targetAngle * trial_set + ppid,
data = data.frame(data_ppt), whichRandom = "ppid", progress = FALSE
)
print(bf)
Bayes factor analysis
--------------
[1] trial_set + ppid : 0.32554 ±1.18%
[2] targetAngle + ppid : 0.05606566 ±1.36%
[3] trial_set + targetAngle + ppid : 0.01790458 ±1.27%
[4] trial_set + targetAngle + trial_set:targetAngle + ppid : 0.003506085 ±2.12%
Against denominator:
mean_trial_set_angle ~ ppid
---
Bayes factor type: BFlinearModel, JZS
bayesfactor_inclusion(bf)
Inclusion Bayes Factors (Model Averaged)
P(prior) P(posterior) Inclusion BF
ppid 1.00 1.00
trial_set 0.60 0.25 0.219
targetAngle 0.60 0.06 0.039
targetAngle:trial_set 0.20 2.50e-03 0.010
* Compared among: all models
* Priors odds: uniform-equal
sr_30_ppt_trial_sets <- sr_30_ppt_training %>%
filter(trial_set < 5) %>%
group_by(ppid, trial_set, targetAngle) %>%
summarise(
mean_trial_set_angle = mean(unsigned_obj_angle)
)
`summarise()` has grouped output by 'ppid', 'trial_set'. You can override using the `.groups` argument.
sr_30_ppt_trial_sets$ppid <- as.factor(sr_30_ppt_trial_sets$ppid)
sr_30_ppt_trial_sets$trial_set <- as.factor(sr_30_ppt_trial_sets$trial_set)
sr_30_ppt_trial_sets$targetAngle <- as.factor(sr_30_ppt_trial_sets$targetAngle)
sr_30_trial_set_devs <- sr_30_ppt_trial_sets %>%
group_by(trial_set, targetAngle) %>%
summarise(
trial_set_mean = mean(mean_trial_set_angle),
trial_set_ci = vector_confint(mean_trial_set_angle)
)
`summarise()` has grouped output by 'trial_set'. You can override using the `.groups` argument.
data_ppt <- sr_30_ppt_trial_sets
data_trial_set <- sr_30_trial_set_devs
# set up plot
p <- data_trial_set %>%
ggplot(
aes(
x = trial_set, y = trial_set_mean
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = NULL
)
# add horizontal lines
p <- p +
geom_hline(
yintercept = c(0, 30), linewidth = 0.4,
colour = "#CCCCCC", linetype = "solid"
) +
geom_hline(
yintercept = c(15), linewidth = 0.4,
colour = "#CCCCCC", linetype = "dashed"
)
# add axis ticks
p <- p +
scale_y_continuous(
limits = c(-15, 40),
breaks = c(0, 15, 30),
labels = c(0, 15, 30)
)
# set font size to 11
p <- p +
theme(text = element_text(size = 11))
# add data points
p <- p +
geom_beeswarm(
data = data_ppt,
aes(y = mean_trial_set_angle, colour = targetAngle),
alpha = 0.5,
size = 1
) +
geom_linerange(aes(
ymin = trial_set_mean - trial_set_ci,
ymax = trial_set_mean + trial_set_ci
), alpha = 0.1, lwd = 2) +
geom_point()
# p <- p +
# scale_color_manual(
# values = c(
# palette$get("s30"), palette$get("s30")
# )
# )
p <- p +
scale_x_discrete(
labels = c(
"Init\nT", "Fin\nT"
)
)
p
# ANOVA using afex (identical values to ez but ez doesn't remove missing rows)
(temp_ANOVA <- aov_car(mean_trial_set_angle ~ targetAngle * trial_set + Error(ppid / (targetAngle * trial_set)), data_ppt))
Anova Table (Type 3 tests)
Response: mean_trial_set_angle
Effect df MSE F ges p.value
1 targetAngle 1.71, 52.97 438.07 0.02 <.001 .962
2 trial_set 1, 31 593.64 40.52 *** .158 <.001
3 targetAngle:trial_set 1.77, 54.89 411.66 0.23 .001 .765
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1
Sphericity correction method: GG
bf <- anovaBF(mean_trial_set_angle ~ targetAngle * trial_set + ppid,
data = data.frame(data_ppt), whichRandom = "ppid", progress = FALSE
)
print(bf)
Bayes factor analysis
--------------
[1] trial_set + ppid : 5473262810 ±0.99%
[2] targetAngle + ppid : 0.05464965 ±1.08%
[3] trial_set + targetAngle + ppid : 305702870 ±4.01%
[4] trial_set + targetAngle + trial_set:targetAngle + ppid : 32635998 ±1.64%
Against denominator:
mean_trial_set_angle ~ ppid
---
Bayes factor type: BFlinearModel, JZS
bayesfactor_inclusion(bf)
Inclusion Bayes Factors (Model Averaged)
P(prior) P(posterior) Inclusion BF
ppid 1.00 1.00
trial_set 0.60 1.00 3.67e+09
targetAngle 0.60 0.06 0.041
targetAngle:trial_set 0.20 5.62e-03 0.023
* Compared among: all models
* Priors odds: uniform-equal
No effects of target Angle (BFincl of 0.04 and 0.08)
dr_30_ppt_trial_sets <- dr_30_ppt_training %>%
filter(trial_set < 5) %>%
group_by(ppid, trial_set, targetAngle) %>%
summarise(
mean_trial_set_angle = mean(unsigned_hand_angle)
)
`summarise()` has grouped output by 'ppid', 'trial_set'. You can override using the `.groups` argument.
dr_30_ppt_trial_sets$ppid <- as.factor(dr_30_ppt_trial_sets$ppid)
dr_30_ppt_trial_sets$trial_set <- as.factor(dr_30_ppt_trial_sets$trial_set)
dr_30_ppt_trial_sets$targetAngle <- as.factor(dr_30_ppt_trial_sets$targetAngle)
dr_30_trial_set_devs <- dr_30_ppt_trial_sets %>%
group_by(trial_set, targetAngle) %>%
summarise(
trial_set_mean = mean(mean_trial_set_angle),
trial_set_ci = vector_confint(mean_trial_set_angle)
)
`summarise()` has grouped output by 'trial_set'. You can override using the `.groups` argument.
data_ppt <- dr_30_ppt_trial_sets
data_trial_set <- dr_30_trial_set_devs
# set up plot
p <- data_trial_set %>%
ggplot(
aes(
x = trial_set, y = trial_set_mean,
color = trial_set
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = "Hand Angle (°)"
)
# add horizontal lines
p <- p +
geom_hline(
yintercept = c(-30, 0, 30), linewidth = 0.4,
colour = "#CCCCCC", linetype = "solid"
) +
geom_hline(
yintercept = c(-15, 15), linewidth = 0.4,
colour = "#CCCCCC", linetype = "dashed"
)
# add axis ticks
p <- p +
scale_y_continuous(
limits = c(-30, 30),
breaks = c(-30, -15, 0, 15, 30),
labels = c(-30, -15, 0, 15, 30)
)
# set font size to 11
p <- p +
theme(text = element_text(size = 11))
# add data points
p <- p +
geom_beeswarm(
data = data_ppt,
aes(y = mean_trial_set_angle, colour = targetAngle),
alpha = 0.5,
size = 1
) +
geom_linerange(aes(
ymin = trial_set_mean - trial_set_ci,
ymax = trial_set_mean + trial_set_ci
), alpha = 0.1, lwd = 2) +
geom_point()
# p <- p +
# scale_color_manual(
# values = c(
# "#555555", "#555555"
# )
# )
p <- p +
scale_x_discrete(
labels = c(
"Init", "Fin"
)
)
p
# ANOVA using afex (identical values to ez but ez doesn't remove missing rows)
(temp_ANOVA <- aov_car(mean_trial_set_angle ~ targetAngle * trial_set + Error(ppid / (targetAngle * trial_set)), data_ppt))
Warning: Missing values for 1 ID(s), which were removed before analysis:
dr_30_22
Below the first few rows (in wide format) of the removed cases with missing data.
Anova Table (Type 3 tests)
Response: mean_trial_set_angle
Effect df MSE F ges p.value
1 targetAngle 1.29, 35.99 195.00 0.86 .006 .387
2 trial_set 1, 28 354.03 0.46 .005 .504
3 targetAngle:trial_set 1.26, 35.40 224.19 1.49 .012 .235
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1
Sphericity correction method: GG
bf <- anovaBF(mean_trial_set_angle ~ targetAngle * trial_set + ppid,
data = data.frame(data_ppt), whichRandom = "ppid", progress = FALSE
)
print(bf)
Bayes factor analysis
--------------
[1] trial_set + ppid : 0.253548 ±1.05%
[2] targetAngle + ppid : 0.09704884 ±0.62%
[3] trial_set + targetAngle + ppid : 0.0255741 ±1.98%
[4] trial_set + targetAngle + trial_set:targetAngle + ppid : 0.006829371 ±1.95%
Against denominator:
mean_trial_set_angle ~ ppid
---
Bayes factor type: BFlinearModel, JZS
bayesfactor_inclusion(bf)
Inclusion Bayes Factors (Model Averaged)
P(prior) P(posterior) Inclusion BF
ppid 1.00 1.00
trial_set 0.60 0.21 0.174
targetAngle 0.60 0.09 0.069
targetAngle:trial_set 0.20 4.94e-03 0.020
* Compared among: all models
* Priors odds: uniform-equal
dr_30_ppt_trial_sets <- dr_30_ppt_training %>%
filter(trial_set < 5) %>%
group_by(ppid, trial_set, targetAngle) %>%
summarise(
mean_trial_set_angle = mean(unsigned_obj_angle)
)
`summarise()` has grouped output by 'ppid', 'trial_set'. You can override using the `.groups` argument.
dr_30_ppt_trial_sets$ppid <- as.factor(dr_30_ppt_trial_sets$ppid)
dr_30_ppt_trial_sets$trial_set <- as.factor(dr_30_ppt_trial_sets$trial_set)
dr_30_ppt_trial_sets$targetAngle <- as.factor(dr_30_ppt_trial_sets$targetAngle)
dr_30_trial_set_devs <- dr_30_ppt_trial_sets %>%
group_by(trial_set, targetAngle) %>%
summarise(
trial_set_mean = mean(mean_trial_set_angle),
trial_set_ci = vector_confint(mean_trial_set_angle)
)
`summarise()` has grouped output by 'trial_set'. You can override using the `.groups` argument.
data_ppt <- dr_30_ppt_trial_sets
data_trial_set <- dr_30_trial_set_devs
# set up plot
p <- data_trial_set %>%
ggplot(
aes(
x = trial_set, y = trial_set_mean
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = NULL
)
# add horizontal lines
p <- p +
geom_hline(
yintercept = c(0, 30), linewidth = 0.4,
colour = "#CCCCCC", linetype = "solid"
) +
geom_hline(
yintercept = c(15), linewidth = 0.4,
colour = "#CCCCCC", linetype = "dashed"
)
# add axis ticks
p <- p +
scale_y_continuous(
limits = c(-15, 40),
breaks = c(0, 15, 30),
labels = c(0, 15, 30)
)
# set font size to 11
p <- p +
theme(text = element_text(size = 11))
# add data points
p <- p +
geom_beeswarm(
data = data_ppt,
aes(y = mean_trial_set_angle, colour = targetAngle),
alpha = 0.5,
size = 1
) +
geom_linerange(aes(
ymin = trial_set_mean - trial_set_ci,
ymax = trial_set_mean + trial_set_ci
), alpha = 0.1, lwd = 2) +
geom_point()
# p <- p +
# scale_color_manual(
# values = c(
# palette$get("s30"), palette$get("s30")
# )
# )
p <- p +
scale_x_discrete(
labels = c(
"Init\nT", "Fin\nT"
)
)
p
# ANOVA using afex (identical values to ez but ez doesn't remove missing rows)
(temp_ANOVA <- aov_car(mean_trial_set_angle ~ targetAngle * trial_set + Error(ppid / (targetAngle * trial_set)), data_ppt))
Warning: Missing values for 1 ID(s), which were removed before analysis:
dr_30_22
Below the first few rows (in wide format) of the removed cases with missing data.
Anova Table (Type 3 tests)
Response: mean_trial_set_angle
Effect df MSE F ges p.value
1 targetAngle 1.63, 45.61 47.71 1.80 .013 .182
2 trial_set 1, 28 88.82 4.00 + .034 .055
3 targetAngle:trial_set 1.42, 39.85 75.67 0.41 .004 .596
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1
Sphericity correction method: GG
bf <- anovaBF(mean_trial_set_angle ~ targetAngle * trial_set + ppid,
data = data.frame(data_ppt), whichRandom = "ppid", progress = FALSE
)
print(bf)
Bayes factor analysis
--------------
[1] trial_set + ppid : 2.838212 ±0.83%
[2] targetAngle + ppid : 0.1859104 ±0.61%
[3] trial_set + targetAngle + ppid : 0.572867 ±1.7%
[4] trial_set + targetAngle + trial_set:targetAngle + ppid : 0.0780265 ±2.05%
Against denominator:
mean_trial_set_angle ~ ppid
---
Bayes factor type: BFlinearModel, JZS
bayesfactor_inclusion(bf)
Inclusion Bayes Factors (Model Averaged)
P(prior) P(posterior) Inclusion BF
ppid 1.00 1.00
trial_set 0.60 0.75 1.96
targetAngle 0.60 0.18 0.145
targetAngle:trial_set 0.20 0.02 0.068
* Compared among: all models
* Priors odds: uniform-equal
No effect of target angle (BFinc = 0.07, 0.14)
dr_30_ppt_incl_clamped <- dr_30_incl_clamp %>%
group_by(ppid, obj_shape_sign, targetAngle) %>%
summarise(
ppt_mean_angle = mean(obj_angle_3cm_move),
ppt_ci_angle = vector_confint(obj_angle_3cm_move)
)
`summarise()` has grouped output by 'ppid', 'obj_shape_sign'. You can override using the `.groups` argument.
dr_30_ppt_incl_clamped$ppid <- factor(dr_30_ppt_incl_clamped$ppid)
dr_30_ppt_incl_clamped$obj_shape_sign <- factor(dr_30_ppt_incl_clamped$obj_shape_sign)
dr_30_ppt_incl_clamped$targetAngle <- factor(dr_30_ppt_incl_clamped$targetAngle)
dr_30_exp_incl_clamped <- dr_30_ppt_incl_clamped %>%
group_by(obj_shape_sign, targetAngle) %>%
summarise(
mean_angle = mean(ppt_mean_angle),
ci_angle = vector_confint(ppt_mean_angle)
)
`summarise()` has grouped output by 'obj_shape_sign'. You can override using the `.groups` argument.
data_ppt <- dr_30_ppt_incl_clamped
data_exp <- dr_30_exp_incl_clamped
# set up plot
p <- data_exp %>%
ggplot(
aes(
x = obj_shape_sign,
y = mean_angle,
color = obj_shape_sign,
shape = targetAngle
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = NULL
)
# add horizontal lines
p <- p +
geom_hline(
yintercept = c(-30, 0, 30), linewidth = 0.4,
colour = "#CCCCCC", linetype = "solid"
) +
geom_hline(
yintercept = c(-15, 15), linewidth = 0.4,
colour = "#CCCCCC", linetype = "dashed"
)
# add axis ticks
p <- p +
scale_y_continuous(
limits = c(-30, 30),
breaks = c(-30, -15, 0, 15, 30),
labels = c(-30, -15, 0, 15, 30)
)
p <- p +
scale_x_discrete(
labels = c(
"CW", "CCW"
)
)
# set font size to 11
p <- p +
theme(text = element_text(size = 11))
# add data points
p <- p +
geom_beeswarm(
data = data_ppt,
aes(
x = obj_shape_sign,
y = ppt_mean_angle,
color = obj_shape_sign,
shape = targetAngle
),
size = 1,
alpha = 0.2
) +
geom_linerange(
aes(
ymin = mean_angle - ci_angle,
ymax = mean_angle + ci_angle
),
alpha = 0.5, lwd = 2
) +
geom_point()
p <- p +
scale_color_manual(
values = c(palette$get("a-1"), palette$get("a-2"))
)
p
# summary statistics
data_ppt %>%
group_by(obj_shape_sign, targetAngle) %>%
summarise(
mean = mean(ppt_mean_angle),
ci = vector_confint(ppt_mean_angle),
n = n()
)
`summarise()` has grouped output by 'obj_shape_sign'. You can override using the `.groups` argument.
# ANOVA using afex (identical values to ez but ez doesn't remove missing rows)
(temp_ANOVA <- aov_car(ppt_mean_angle ~ targetAngle * obj_shape_sign + Error(ppid / (targetAngle * obj_shape_sign)), data_ppt))
Anova Table (Type 3 tests)
Response: ppt_mean_angle
Effect df MSE F ges p.value
1 targetAngle 1.35, 39.16 113.20 10.24 ** .097 .001
2 obj_shape_sign 1, 29 170.89 6.81 * .074 .014
3 targetAngle:obj_shape_sign 1.93, 55.97 11.77 0.38 <.001 .675
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1
Sphericity correction method: GG
bf <- anovaBF(ppt_mean_angle ~ targetAngle * obj_shape_sign + ppid,
data = data.frame(data_ppt), whichRandom = "ppid", progress = FALSE
)
print(bf)
Bayes factor analysis
--------------
[1] obj_shape_sign + ppid : 164.2226 ±0.77%
[2] targetAngle + ppid : 457.2232 ±0.66%
[3] obj_shape_sign + targetAngle + ppid : 178501.1 ±1.06%
[4] obj_shape_sign + targetAngle + obj_shape_sign:targetAngle + ppid : 18848.22 ±1.39%
Against denominator:
ppt_mean_angle ~ ppid
---
Bayes factor type: BFlinearModel, JZS
bayesfactor_inclusion(bf)
Inclusion Bayes Factors (Model Averaged)
P(prior) P(posterior) Inclusion BF
ppid 1.00 1.00
obj_shape_sign 0.60 1.00 287.36
targetAngle 0.60 1.00 798.14
obj_shape_sign:targetAngle 0.20 0.10 0.421
* Compared among: all models
* Priors odds: uniform-equal
dr_30_ppt_excl_clamped <- dr_30_excl_clamp %>%
group_by(ppid, obj_shape_sign, targetAngle) %>%
summarise(
ppt_mean_angle = mean(obj_angle_3cm_move),
ppt_ci_angle = vector_confint(obj_angle_3cm_move)
)
Warning: There were 3 warnings in `summarise()`.
The first warning was:
ℹ In argument: `ppt_ci_angle = vector_confint(obj_angle_3cm_move)`.
ℹ In group 37: `ppid = "dr_30_15"`, `obj_shape_sign = -1`, `targetAngle = 45`.
Caused by warning in `qt()`:
! NaNs produced
ℹ Run ]8;;ide:run:dplyr::last_dplyr_warnings()dplyr::last_dplyr_warnings()]8;; to see the 2 remaining warnings.`summarise()` has grouped output by 'ppid', 'obj_shape_sign'. You can override using the `.groups` argument.
dr_30_ppt_excl_clamped$ppid <- factor(dr_30_ppt_excl_clamped$ppid)
dr_30_ppt_excl_clamped$obj_shape_sign <- factor(dr_30_ppt_excl_clamped$obj_shape_sign)
dr_30_ppt_excl_clamped$targetAngle <- factor(dr_30_ppt_excl_clamped$targetAngle)
dr_30_exp_excl_clamped <- dr_30_ppt_excl_clamped %>%
group_by(obj_shape_sign, targetAngle) %>%
summarise(
mean_angle = mean(ppt_mean_angle),
ci_angle = vector_confint(ppt_mean_angle)
)
`summarise()` has grouped output by 'obj_shape_sign'. You can override using the `.groups` argument.
data_ppt <- dr_30_ppt_excl_clamped
data_exp <- dr_30_exp_excl_clamped
# set up plot
p <- data_exp %>%
ggplot(
aes(
x = obj_shape_sign,
y = mean_angle,
color = obj_shape_sign,
shape = targetAngle
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = NULL
)
# add horizontal lines
p <- p +
geom_hline(
yintercept = c(-30, 0, 30), linewidth = 0.4,
colour = "#CCCCCC", linetype = "solid"
) +
geom_hline(
yintercept = c(-15, 15), linewidth = 0.4,
colour = "#CCCCCC", linetype = "dashed"
)
# add axis ticks
p <- p +
scale_y_continuous(
limits = c(-30, 30),
breaks = c(-30, -15, 0, 15, 30),
labels = c(-30, -15, 0, 15, 30)
)
p <- p +
scale_x_discrete(
labels = c(
"CW", "CCW"
)
)
# set font size to 11
p <- p +
theme(text = element_text(size = 11))
# add data points
p <- p +
geom_beeswarm(
data = data_ppt,
aes(
x = obj_shape_sign,
y = ppt_mean_angle,
color = obj_shape_sign,
shape = targetAngle
),
size = 1,
alpha = 0.2
) +
geom_linerange(
aes(
ymin = mean_angle - ci_angle,
ymax = mean_angle + ci_angle
),
alpha = 0.5, lwd = 2
) +
geom_point()
p <- p +
scale_color_manual(
values = c(palette$get("a-1"), palette$get("a-2"))
)
p
# summary statistics
data_ppt %>%
group_by(obj_shape_sign, targetAngle) %>%
summarise(
mean = mean(ppt_mean_angle),
ci = vector_confint(ppt_mean_angle),
n = n()
)
`summarise()` has grouped output by 'obj_shape_sign'. You can override using the `.groups` argument.
# ANOVA using afex (identical values to ez but ez doesn't remove missing rows)
(temp_ANOVA <- aov_car(ppt_mean_angle ~ targetAngle * obj_shape_sign + Error(ppid / (targetAngle * obj_shape_sign)), data_ppt))
Anova Table (Type 3 tests)
Response: ppt_mean_angle
Effect df MSE F ges p.value
1 targetAngle 1.56, 45.33 107.75 11.99 *** .119 <.001
2 obj_shape_sign 1, 29 110.13 3.92 + .028 .057
3 targetAngle:obj_shape_sign 1.83, 53.18 21.25 3.43 * .009 .044
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1
Sphericity correction method: GG
bf <- anovaBF(ppt_mean_angle ~ targetAngle * obj_shape_sign + ppid,
data = data.frame(data_ppt), whichRandom = "ppid", progress = FALSE
)
print(bf)
Bayes factor analysis
--------------
[1] obj_shape_sign + ppid : 2.234713 ±2.56%
[2] targetAngle + ppid : 21151.1 ±0.61%
[3] obj_shape_sign + targetAngle + ppid : 81687.42 ±4.2%
[4] obj_shape_sign + targetAngle + obj_shape_sign:targetAngle + ppid : 18830.67 ±2.83%
Against denominator:
ppt_mean_angle ~ ppid
---
Bayes factor type: BFlinearModel, JZS
bayesfactor_inclusion(bf)
Inclusion Bayes Factors (Model Averaged)
P(prior) P(posterior) Inclusion BF
ppid 1.00 1.00
obj_shape_sign 0.60 0.83 3.17
targetAngle 0.60 1.00 2.51e+04
obj_shape_sign:targetAngle 0.20 0.15 0.732
* Compared among: all models
* Priors odds: uniform-equal
# posthoc tests
(m1 <- emmeans(temp_ANOVA, ~ targetAngle * obj_shape_sign))
targetAngle obj_shape_sign emmean SE df lower.CL upper.CL
X45 X.1 4.446 1.45 29 1.471 7.420
X90 X.1 -2.462 1.52 29 -5.563 0.639
X135 X.1 -0.603 1.82 29 -4.326 3.121
X45 X1 2.849 1.61 29 -0.435 6.133
X90 X1 -4.647 1.56 29 -7.835 -1.460
X135 X1 -6.113 2.09 29 -10.393 -1.832
Confidence level used: 0.95
pairs(m1)
contrast estimate SE df t.ratio p.value
X45 X.1 - X90 X.1 6.91 1.43 29 4.841 0.0005
X45 X.1 - X135 X.1 5.05 2.12 29 2.383 0.1955
X45 X.1 - X45 X1 1.60 1.56 29 1.027 0.9051
X45 X.1 - X90 X1 9.09 1.88 29 4.834 0.0005
X45 X.1 - X135 X1 10.56 2.66 29 3.976 0.0052
X90 X.1 - X135 X.1 -1.86 1.83 29 -1.018 0.9081
X90 X.1 - X45 X1 -5.31 2.03 29 -2.615 0.1256
X90 X.1 - X90 X1 2.18 1.56 29 1.396 0.7287
X90 X.1 - X135 X1 3.65 2.29 29 1.597 0.6070
X135 X.1 - X45 X1 -3.45 2.71 29 -1.275 0.7956
X135 X.1 - X90 X1 4.04 2.36 29 1.715 0.5333
X135 X.1 - X135 X1 5.51 2.25 29 2.446 0.1739
X45 X1 - X90 X1 7.50 1.67 29 4.492 0.0013
X45 X1 - X135 X1 8.96 2.40 29 3.740 0.0095
X90 X1 - X135 X1 1.47 1.53 29 0.956 0.9280
P value adjustment: tukey method for comparing a family of 6 estimates
# helper function
average_circle <- function(num_vec) {
# Convert vectors to radians
vectors_rad <- lapply(num_vec, function(v) rad(v))
# Calculate average for each dimension
circular_mean <- mean(circular(vectors_rad), na.rm = TRUE)
# Convert the average vector back to degrees
deg(circular_mean)
}
# isolate all trials where baseline_block is TRUE
dr_30_baseline <- dr_30_all %>%
filter(baseline_block == TRUE)
# make ppid, obj_shape, targetAngle factors
dr_30_baseline$ppid <- factor(dr_30_baseline$ppid)
dr_30_baseline$obj_shape <- factor(dr_30_baseline$obj_shape)
dr_30_baseline$targetAngle <- factor(dr_30_baseline$targetAngle)
rot_at_pickup_summary <- dr_30_baseline %>%
group_by(ppid, obj_shape, targetAngle) %>%
summarise(
n()
)
`summarise()` has grouped output by 'ppid', 'obj_shape'. You can override using the `.groups` argument.
# add empty columns
rot_at_pickup_summary$mean_rot_x_at_pickup <- NA
rot_at_pickup_summary$ci_rot_x_at_pickup <- NA
rot_at_pickup_summary$mean_rot_y_at_pickup <- NA
rot_at_pickup_summary$ci_rot_y_at_pickup <- NA
rot_at_pickup_summary$mean_rot_z_at_pickup <- NA
rot_at_pickup_summary$ci_rot_z_at_pickup <- NA
# loop through rows of rot_at_pickup_summary and calculate average rotation
for (i in 1:nrow(rot_at_pickup_summary)) {
# get ppid, obj_shape, targetAngle
row_ppid <- rot_at_pickup_summary$ppid[i]
row_obj_shape <- rot_at_pickup_summary$obj_shape[i]
row_targetAngle <- rot_at_pickup_summary$targetAngle[i]
# get all rows for this ppid, obj_shape, targetAngle
temp_data <- dr_30_baseline %>%
filter(ppid == row_ppid, obj_shape == row_obj_shape, targetAngle == row_targetAngle)
# get all hand_rot_x_at_pickup values
rot_x <- temp_data$hand_rot_x_at_pickup
# get all hand_rot_y_at_pickup values
rot_y <- temp_data$hand_rot_y_at_pickup
# get all hand_rot_z_at_pickup values
rot_z <- temp_data$hand_rot_z_at_pickup
# add to rot_at_pickup_summary
rot_at_pickup_summary$mean_rot_x_at_pickup[i] <- average_circle(rot_x)
rot_at_pickup_summary$ci_rot_x_at_pickup[i] <- vector_confint(rot_x)
rot_at_pickup_summary$mean_rot_y_at_pickup[i] <- average_circle(rot_y)
rot_at_pickup_summary$ci_rot_y_at_pickup[i] <- vector_confint(rot_y)
rot_at_pickup_summary$mean_rot_z_at_pickup[i] <- average_circle(rot_z)
rot_at_pickup_summary$ci_rot_z_at_pickup[i] <- vector_confint(rot_z)
}
# summarize
rot_at_pickup_summary2 <- rot_at_pickup_summary %>%
group_by(obj_shape, targetAngle) %>%
summarise(
mean_rot_x_at_pickup2 = mean(mean_rot_x_at_pickup),
ci_rot_x_at_pickup2 = vector_confint(mean_rot_x_at_pickup),
mean_rot_y_at_pickup2 = mean(mean_rot_y_at_pickup),
ci_rot_y_at_pickup2 = vector_confint(mean_rot_y_at_pickup),
mean_rot_z_at_pickup2 = mean(mean_rot_z_at_pickup),
ci_rot_z_at_pickup2 = vector_confint(mean_rot_z_at_pickup)
)
`summarise()` has grouped output by 'obj_shape'. You can override using the `.groups` argument.
# set up plot
p <- rot_at_pickup_summary %>%
ggplot(
aes(
x = obj_shape,
y = mean_rot_x_at_pickup,
color = targetAngle
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = NULL
) +
# add data points
geom_beeswarm(
aes(
x = obj_shape,
y = mean_rot_x_at_pickup,
color = targetAngle
),
size = 1,
alpha = 0.2
) +
geom_linerange(
data = rot_at_pickup_summary2,
aes(
y = mean_rot_x_at_pickup2,
ymin = mean_rot_x_at_pickup2 - ci_rot_x_at_pickup2,
ymax = mean_rot_x_at_pickup2 + ci_rot_x_at_pickup2
),
alpha = 0.5, lwd = 2
) +
geom_point(
data = rot_at_pickup_summary2,
aes(
x = obj_shape,
y = mean_rot_x_at_pickup2,
color = targetAngle
)
)
# same as above but add y in a different plot
q <- rot_at_pickup_summary %>%
ggplot(
aes(
x = obj_shape,
y = mean_rot_y_at_pickup,
color = targetAngle
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = NULL
) +
# add data points
geom_beeswarm(
aes(
x = obj_shape,
y = mean_rot_y_at_pickup,
color = targetAngle
),
size = 1,
alpha = 0.2
) +
geom_linerange(
data = rot_at_pickup_summary2,
aes(
y = mean_rot_y_at_pickup2,
ymin = mean_rot_y_at_pickup2 - ci_rot_y_at_pickup2,
ymax = mean_rot_y_at_pickup2 + ci_rot_y_at_pickup2
),
alpha = 0.5, lwd = 2
) +
geom_point(
data = rot_at_pickup_summary2,
aes(
x = obj_shape,
y = mean_rot_y_at_pickup2,
color = targetAngle
)
)
# same as above but add z in a different plot
r <- rot_at_pickup_summary %>%
ggplot(
aes(
x = obj_shape,
y = mean_rot_z_at_pickup,
color = targetAngle
)
) +
theme_classic() +
theme(legend.position = "none") +
labs(
x = NULL,
y = NULL
) +
# add data points
geom_beeswarm(
aes(
x = obj_shape,
y = mean_rot_z_at_pickup,
color = targetAngle
),
size = 1,
alpha = 0.2
) +
geom_linerange(
data = rot_at_pickup_summary2,
aes(
y = mean_rot_z_at_pickup2,
ymin = mean_rot_z_at_pickup2 - ci_rot_z_at_pickup2,
ymax = mean_rot_z_at_pickup2 + ci_rot_z_at_pickup2
),
alpha = 0.5, lwd = 2
) +
geom_point(
data = rot_at_pickup_summary2,
aes(
x = obj_shape,
y = mean_rot_z_at_pickup2,
color = targetAngle
)
)
# plots
p
q
r
# ANOVA using afex (identical values to ez but ez doesn't remove missing rows)
(temp_ANOVA <- aov_car(mean_rot_x_at_pickup ~ obj_shape * targetAngle + Error(ppid / (obj_shape * targetAngle)), rot_at_pickup_summary))
Anova Table (Type 3 tests)
Response: mean_rot_x_at_pickup
Effect df MSE F ges p.value
1 obj_shape 1, 29 2.50 0.37 <.001 .547
2 targetAngle 1.76, 51.15 2.33 3.93 * .001 .031
3 obj_shape:targetAngle 1.83, 53.02 1.37 1.42 <.001 .250
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘+’ 0.1 ‘ ’ 1
Sphericity correction method: GG
bf <- anovaBF(mean_rot_x_at_pickup ~ obj_shape * targetAngle + ppid,
data = data.frame(rot_at_pickup_summary), whichRandom = "ppid", progress = FALSE
)
print(bf)
Bayes factor analysis
--------------
[1] obj_shape + ppid : 0.1978091 ±0.93%
[2] targetAngle + ppid : 2.495498 ±0.81%
[3] obj_shape + targetAngle + ppid : 0.5158836 ±2.5%
[4] obj_shape + targetAngle + obj_shape:targetAngle + ppid : 0.1111915 ±2.06%
Against denominator:
mean_rot_x_at_pickup ~ ppid
---
Bayes factor type: BFlinearModel, JZS
bayesfactor_inclusion(bf)
Inclusion Bayes Factors (Model Averaged)
P(prior) P(posterior) Inclusion BF
ppid 1.00 1.00
obj_shape 0.60 0.19 0.157
targetAngle 0.60 0.72 1.74
obj_shape:targetAngle 0.20 0.03 0.106
* Compared among: all models
* Priors odds: uniform-equal
# posthoc tests
(m1 <- emmeans(temp_ANOVA, ~ obj_shape * targetAngle))
obj_shape targetAngle emmean SE df lower.CL upper.CL
cube X45 -4.73 1.49 29 -7.78 -1.682
sphere X45 -4.66 1.40 29 -7.52 -1.797
cube X90 -3.99 1.47 29 -6.99 -0.987
sphere X90 -3.95 1.46 29 -6.95 -0.962
cube X135 -3.95 1.45 29 -6.93 -0.975
sphere X135 -4.49 1.42 29 -7.39 -1.592
Confidence level used: 0.95
pairs(m1)
contrast estimate SE df t.ratio p.value
cube X45 - sphere X45 -0.07417 0.317 29 -0.234 0.9999
cube X45 - cube X90 -0.74142 0.367 29 -2.018 0.3570
cube X45 - sphere X90 -0.77803 0.468 29 -1.664 0.5651
cube X45 - cube X135 -0.78146 0.307 29 -2.547 0.1437
cube X45 - sphere X135 -0.23954 0.367 29 -0.654 0.9856
sphere X45 - cube X90 -0.66724 0.328 29 -2.034 0.3484
sphere X45 - sphere X90 -0.70386 0.298 29 -2.360 0.2036
sphere X45 - cube X135 -0.70729 0.273 29 -2.590 0.1321
sphere X45 - sphere X135 -0.16537 0.295 29 -0.560 0.9929
cube X90 - sphere X90 -0.03662 0.344 29 -0.106 1.0000
cube X90 - cube X135 -0.04004 0.306 29 -0.131 1.0000
cube X90 - sphere X135 0.50187 0.435 29 1.153 0.8551
sphere X90 - cube X135 -0.00342 0.323 29 -0.011 1.0000
sphere X90 - sphere X135 0.53849 0.405 29 1.329 0.7670
cube X135 - sphere X135 0.54192 0.340 29 1.594 0.6087
P value adjustment: tukey method for comparing a family of 6 estimates
# Fin